home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 / Ham Radio 2000.iso / ham2000 / packet / monax25 / rr.c < prev    next >
Text File  |  1987-10-18  |  3KB  |  163 lines

  1. /* rr.c - Report total RR frames per interval.
  2.    This module is part of report.exe
  3.                   
  4.    Language = Microsoft C version 4.0
  5.  
  6.  
  7.    This source is distributed freely and may be copied and
  8.    redistributed with the following provisos:
  9.    
  10.            You may not sell it, nor may you charge for making 
  11.            copies beyond the actual cost of mailing and media.
  12.                       
  13.    Written by Skip Hansen WB6YMH and Harold Price NK6K.
  14.  
  15.    Feedback is desired.
  16.  
  17.    RCP/M (213) 541-2503 300/1200/2400 baud
  18.    or via packet WB6YMH @ WB6YMH-2 or 
  19.          NK6K @ NK6K
  20.  
  21.    Modification history:
  22.  
  23.     8/10/87         NK6K: Initial release.    
  24.     ver 1.0         
  25.  
  26.    10/18/87     NK6K: First general release.
  27.    ver 1.1
  28. */
  29. #define LINT_ARGS
  30. #include "monfile.h"
  31. #include <stdio.h>
  32. #include <memory.h>
  33. static struct CIRCUIT_RECORD ccrec;
  34. static struct FREQ_RECORD cfrec;
  35.  
  36. extern FILE *fin,*fout;
  37.  
  38. static long total_packets;
  39. static long total_rr;
  40. static long total_i;
  41.  
  42. static char fbuf[257];
  43. static char started;
  44. static unsigned long time_stamp;
  45. static unsigned int all_cir,user_cir;
  46. static int tmp;
  47. static long recnum;
  48.  
  49.  
  50. report_rr()
  51. {
  52.    started=0;
  53.    recnum=0;
  54.    
  55.    total_packets=total_i=total_rr=0;
  56.    while (1){
  57.     if (fgets(fbuf,256,fin)==NULL) {
  58.         if (started) rrdump_it();
  59.         return;
  60.         }
  61.     recnum++;
  62.     if (fbuf[0]=='T') {
  63.         if (started) rrdump_it();
  64.         tmp=sscanf(fbuf+2,"%lu",&time_stamp);    
  65.         if (tmp!=1) {
  66.             cprintf("*** bad Time rec, number %lu ***\r\n",recnum);
  67.             }
  68.         started=1;
  69.         }
  70.  
  71.     else if (fbuf[0]== FREQ_TYPE) {
  72.         tmp=sscanf(fbuf+2,"%lu,%lu,%lu,%lu,%lu,%lu,%lu,%lu,%lu,%lu,%lu",
  73.             &cfrec.t_packets,
  74.             &cfrec.t_bytes,
  75.             &cfrec.u_packets,
  76.             &cfrec.u_bytes,
  77.             &cfrec.l32,
  78.             &cfrec.l64,
  79.             &cfrec.l128,
  80.             &cfrec.l256,
  81.             &cfrec.g256,
  82.             &cfrec.dcd_on_ticks,
  83.             &cfrec.dcd_off_ticks);
  84.  
  85.         if (tmp!=11) {
  86.             cprintf("*** bad Freq rec, number %lu ***\r\n",recnum); 
  87.             break;
  88.             }
  89.         }
  90.         
  91.     else if (fbuf[0]=='C') {
  92.         all_cir++;
  93.         tmp = sscanf(fbuf+2,
  94. "%[^,],%[^,],%u,%u,%lu,%lu,%lu,%lu,%lu,%lu,%lu,%lu,%lu,%lu,\
  95. %lu,%lu,%lu,%lu,%lu,%lu,%lu,%lu,%lu,%lu,%lu,%lu,%lu,%lu,%lu,%lu,%lu,%lu",
  96.         ccrec.to,        
  97.         ccrec.from,        
  98.         &ccrec.digis,        
  99.         &ccrec.pid,
  100.         &ccrec.u_dpackets,    
  101.         &ccrec.nd_dpackets,    
  102.         &ccrec.t_dpackets,    
  103.         &ccrec.nd_packets,    
  104.         &ccrec.t_packets,    
  105.         &ccrec.u_dbytes,        
  106.         &ccrec.nd_dbytes,    
  107.         &ccrec.t_dbytes,        
  108.         &ccrec.nd_bytes,        
  109.         &ccrec.t_bytes,        
  110.         &ccrec.c_time,        
  111.         &ccrec.sabm,
  112.         &ccrec.ua,
  113.         &ccrec.disc,
  114.         &ccrec.dm,
  115.         &ccrec.rej,
  116.         &ccrec.rr,
  117.         &ccrec.rnr,
  118.         &ccrec.i,
  119.         &ccrec.ui,
  120.         &ccrec.frmr,
  121.         &ccrec.poll,
  122.         &ccrec.final,
  123.         &ccrec.l32,    
  124.         &ccrec.l64,    
  125.         &ccrec.l128,
  126.         &ccrec.l256,
  127.         &ccrec.g256);
  128.  
  129.         if (tmp!=32) {
  130.             cprintf("*** bad Circuit rec, number %lu ***\r\n",recnum); 
  131.             break;
  132.             }
  133.  
  134.         
  135.  
  136. /*n* fix this later */
  137.         if (ccrec.digis==0) 
  138.         if ((ccrec.nd_dpackets-ccrec.u_dpackets) >= 0) {
  139.             total_packets += ccrec.t_packets;
  140.             total_i += ccrec.i;
  141.             total_rr += ccrec.rr;
  142.              }
  143.         }
  144.     
  145.  
  146.     }
  147.    }
  148.  
  149.         
  150.  
  151.  
  152. rrdump_it()
  153. {
  154. long tmpi;
  155.     fprintf(fout,"%lu,%lu,%lu,%lu\n",
  156.         time_stamp, total_packets, total_i, total_rr);
  157.  
  158.    total_packets=total_i=total_rr=0;
  159.  
  160.  
  161.     }
  162.  
  163.